/*****************************************************************************
*
*  PROJECT:     SlipStream
*               (KeyBinds)
*  LICENSE:     GNU General Public License v3 - http://www.gnu.org/licenses/gpl.html

*  DEVELOPERS:  Philip Farquharson	<B00137077@studentmail.uws.ac.uk>
*				John Gray			<B00145524@studentmail.uws.ac.uk>		
*				Zohaib Bhatti		<B00104280@studentmail.uws.ac.uk>
*				Euan Hislop			<B00138636@studentmail.uws.ac.uk>
*
*****************************************************************************/
#ifndef CKEYBIND_H
#define CKEYBIND_H

#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <windowsx.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctime>

typedef void (*KeybindCallback) (); // type definition for our callback function

class CKeyBind
{

	public:
		// Type of bind
		// Simple - Function will be called every time the key is pressed or held down.
		// Toggle - Function will be called only when pressed, not when held.
		typedef enum eBindType
		{
			BIND_SIMPLE,
			BIND_TOGGLE
		};

		// Key - Simply they key which the function will respond to
		typedef enum eKey
		{
			VK_A = 0x41,
			VK_B = 0x42,
			VK_C = 0x43,
			VK_D = 0x44,
			VK_E = 0x45,
			VK_F = 0x46,
			VK_G = 0x47,
			VK_H = 0x48,
			VK_I = 0x49,
			VK_J = 0x4A,
			VK_K = 0x4B,
			VK_L = 0x4C,
			VK_M = 0x4D,
			VK_N = 0x4E,
			VK_O = 0x4F,
			VK_P = 0x50,
			VK_Q = 0x51,
			VK_R = 0x52,
			VK_S = 0x53,
			VK_T = 0x54,
			VK_U = 0x55,
			VK_V = 0x56,
			VK_W = 0x57,
			VK_X = 0x58,
			VK_Y = 0x59,
			VK_Z = 0x5A,
			VK_PLUS = 0xBB,
			VK_MINUS = 0xBD,
			VK_FKEY_F1 = 0x70,
			VK_FKEY_F2 = 0x71,
			VK_FKEY_F3 = 0x72,
			VK_FKEY_F4 = 0x73,
			VK_FKEY_F5 = 0x74,
			VK_FKEY_F6 = 0x75,
			VK_FKEY_F7 = 0x76,
			VK_FKEY_F8 = 0x77,
			VK_FKEY_F9 = 0x78,
			VK_FKEY_F10 = 0x79,
			VK_FKEY_F11 = 0x7A,
			VK_FKEY_F12 = 0x7B,		
			VK_ESC = 0x1B,
		} eKey;

		// Constructor, takes a void function, a key, and bind type.
		CKeyBind ( KeybindCallback CallBack, eKey key, eBindType bindType );

		// Destructor
		~CKeyBind ( void );

		eKey getKey ()										{ return m_key; }			// returns key
		int getType ()										{ return m_bindType; }		// returns bind type
		int getMS ()										{ return m_ms; }			// returns time in milliseconds (Internal use only)
		KeybindCallback getCallback ()						{ return m_CallBack;}		// returns the void function of the callback

		void Proc ();

	private:
		void Trigger ( void ); // Calls the callback function

		int m_ms; // time in milliseconds
		eBindType m_bindType; // bind type
		eKey m_key; // keyboard key
		KeybindCallback m_CallBack; // callback void function
};
#endif